<#include "header.ftl" />
<#setting classic_compatible=true>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>文件管理</title>
    <link rel="stylesheet" href="${SERVER_SIDE_CONTEXT}/statics/css/data_mart.css"/>
    <link rel="stylesheet" href="${SERVER_SIDE_CONTEXT}/statics/font-awesome/css/font-awesome.min.css"/>
    <script src="${SERVER_SIDE_CONTEXT}/statics/js/jquery-1.11.1.js"></script>

    <script type="application/javascript">
        function downloadIt(options) {
            let config = $.extend(true, {method: 'post'}, options);
            let form = $("<form>");
            form.attr("style", "display:none");
            form.attr("target", "");
            form.attr("method", config.method);
            form.attr('action', config.url);

            for (let key in config.data) {
                form.append('<input type="hidden" name="' + key + '" value="' + config.data[key] + '" />');
            }

            $("body").append(form);
            form.submit();
            form.remove();
        }
    </script>

    <style type="text/css">
        form {
            margin-bottom: 50px;
        }

        .input {
            border-radius: 15px;
            width: 80px;
            height: 30px;
        }
    </style>
</head>
<body>
<hr/>
<h2>文件上传</h2>
<hr/>
<form name="Form1" action="${SERVER_SIDE_CONTEXT}/fileOperations/fileUpload1" method="post"
      enctype="multipart/form-data">
    <h3>1. 采用流的方式上传文件</h3>
    <input type="file" name="file">
    <input type="submit" value="upload" class="input"/>
</form>

<form name="Form2" action="${SERVER_SIDE_CONTEXT}/fileOperations/fileUpload2" method="post"
      enctype="multipart/form-data">
    <h3>2. 采用multipart提供的file.transfer方法上传文件（多文件上传——一次选一个， 选多次）</h3>
    <input type="file" name="files">
    <input type="file" name="files">
    <input type="file" name="files">
    <input type="submit" value="upload" class="input"/>
</form>

<form name="Form3" action="${SERVER_SIDE_CONTEXT}/fileOperations/springUpload" method="post"
      enctype="multipart/form-data">
    <h3>3. 使用spring mvc提供的类的方法上传文件(支持多文件上传——一次性选多文件)</h3>
    <input type="file" name="file" multiple/>
    <input type="submit" value="upload" class="input"/>
</form>

<hr/>
<h2>文件下载</h2>
<hr/>
<#--<form action="${SERVER_SIDE_CONTEXT}/fileOperations/download" method="post">
    <input type="hidden" name="filePath" value="H:/test/ssm/" />
    <input type="hidden" name="fileName" value="nice.pptx" />
    <input type="submit" value="下载文件" />
</form>-->

<a href="#" onclick="return downloadIt({
        url:'${SERVER_SIDE_CONTEXT}/fileOperations/download',
        data:{
        filePath:'H:/test/ssm/',
        fileName:'nice.pptx'}
        });">nice.pptx</a>
</body>
</html>